//
//  MSQueryRelationsCell.m
//  觅尚
//
//  Created by No.8 on 2019/4/17.
//  Copyright © 2019 No.8. All rights reserved.
//

#import "MSQueryRelationsCell.h"

@implementation MSQueryRelationsCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    MSQueryRelationsCell * cell = [tableView dequeueReusableCellWithIdentifier:[MSQueryRelationsCell ID]];
    cell = [[MSQueryRelationsCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[MSQueryRelationsCell ID]];
    cell.backgroundColor = backgroundcolor;
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setMember];
        
    }
    return self;
}
- (void)setMember{
    
    self.backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 180 * px)];
    self.backView.backgroundColor = [UIColor clearColor];
    [self addSubview:self.backView];
    
    
    
    self.photoIMG = [[UIImageView alloc] initWithFrame:CGRectMake(50 * px, 20 * px, 140 * px, 140 * px)];
    self.photoIMG.backgroundColor = BackViewColor;
    [self.backView addSubview:self.photoIMG];
    
    /** 时间*/
    self.NameLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.photoIMG.frame) + 20 * px, self.photoIMG.y, 150 * px, 60 * px)];
    self.NameLabel.textColor = [UIColor whiteColor];
    self.NameLabel.text = @"xxxxx";
    self.NameLabel.textAlignment = NSTextAlignmentLeft;
    self.NameLabel.font = [UIFont systemFontOfSize:SYRealValue(28 / 2)];
    [self.backView addSubview:self.NameLabel];
    
    
    /** 职位*/
    self.PositionLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.NameLabel.frame) + 20 * px, self.NameLabel.y, self.backView.width / 2, self.NameLabel.height)];
    self.PositionLabel.textColor = [UIColor grayColor];
    self.PositionLabel.text = @"￥23287876";
    self.PositionLabel.textAlignment = self.NameLabel.textAlignment;
    self.PositionLabel.font = self.NameLabel.font;
    [self.backView addSubview:self.PositionLabel];
    
    
    
    
    
    /** 金额*/
    self.EmployeeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.NameLabel.x, CGRectGetMaxY(self.NameLabel.frame) + 20 * px, self.PositionLabel.width, self.NameLabel.height)];
    self.EmployeeLabel.textColor = [UIColor grayColor];
    self.EmployeeLabel.text = @"￥微信";
    self.EmployeeLabel.textAlignment = self.NameLabel.textAlignment;
    self.EmployeeLabel.font = self.NameLabel.font;
    [self.backView addSubview:self.EmployeeLabel];
    
    
    /** 绑定按钮*/
    self.BindingButton = [[UIButton alloc] initWithFrame:CGRectMake(self.backView.width - 200 * px, self.NameLabel.y + 30 * px, 160 * px, self.NameLabel.height)];
    [self.BindingButton setTitle:@"绑定" forState:UIControlStateNormal];
    self.BindingButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(28 / 2)];
    [self.BindingButton  setTitleColor:WYCRGBColor(55, 115, 206) forState:UIControlStateNormal];
    [self.BindingButton  addTarget:self action:@selector(BindingButtonClick) forControlEvents:UIControlEventTouchUpInside];
    //设置边框颜色
    self.BindingButton.layer.borderColor = [WYCRGBColor(32, 62, 105) CGColor];
    //设置边框宽度
    self.BindingButton.layer.borderWidth = 1.0f;
    //给按钮设置角的弧度
    self.BindingButton.layer.cornerRadius = self.NameLabel.height  / 2;
    [self.backView  addSubview:self.BindingButton];
    
    
    
    self.LinView = [[UIView alloc] initWithFrame:CGRectMake(self.NameLabel.x, self.backView.height - 1, ScreenWidth - self.NameLabel.width, 1)];
    self.LinView.backgroundColor = BackViewColor;
    [self.backView addSubview:self.LinView];
    
}
- (void)setQueryRelationModel:(MSQueryRelationModel *)QueryRelationModel{
    
    _QueryRelationModel = QueryRelationModel;
    
//    [self.photoIMG sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",QueryRelationModel.avatarUrl]]];
    [self.photoIMG sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",QueryRelationModel.avatarUrl]]];
    WYCLog(@"----------%@",QueryRelationModel.avatarUrl);
    
    self.NameLabel.text = [NSString stringWithFormat:@"%@",QueryRelationModel.userName];
    
    self.PositionLabel.text = [NSString stringWithFormat:@"(%@/%@)",QueryRelationModel.stn_alias,QueryRelationModel.pst_alias];
    
    self.EmployeeLabel.text = [NSString stringWithFormat:@"员工ID:%@",QueryRelationModel.userCode];
    
}

+(NSString *)ID{
    return @"cell";
}
- (void)BindingButtonClick{
    if (self.BindingButtonDelegate && [self.BindingButtonDelegate respondsToSelector:@selector(ClickBindingButtonUid:)]) {
        [self.BindingButtonDelegate ClickBindingButtonUid:self.QueryRelationModel.uid];
    }
    
}
@end
